import request from '@/router/axios';
// import { bladeUrl } from '@/config';
// var request=window.axios;
export const loginByUsername = (data) =>
  request({
    url: '/api/Login/Login',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: data
  });


export const refreshToken = (refresh_token, tenantId) => request({
  url: '/api/blade-auth/oauth/token',
  method: 'post',
  headers: {
    'Tenant-Id': tenantId
  },
  params: {
    tenantId,
    refresh_token,
    grant_type: "refresh_token",
    scope: "all",
  }
});

export const getButtons = () => request({
  url: '/api/blade-system/menu/buttons',
  method: 'get'
});

export const getCaptcha = () => request({
  url: '/api/blade-auth/oauth/captcha',
  method: 'get'
});

export const logout = () => request({
  url: '/api/Login/Logout',
  method: 'post'
});

export const getUserInfo = () => request({
  url: '/api/User/Info',
  method: 'get'
});

export const sendLogs = (list) => request({
  url: '/api/blade-auth/oauth/logout',
  method: 'post',
  data: list
});

//获取配置参数
export const getConfigApi = () => request({
  url: '/api/Config/Get',
  method: 'get'
});

//初始化
export const initializeDataBase = (data) => request({
  url: '/api/Initialize/Initialize',
  method: 'post',
  params: data
});

//获取手机验证码
export const getPhoneValidationCode = (data) => request({
  url: 'api/getValidationCode',
  method: 'post',
  params: data
});

//注册用户创建组织
export const createTenant = (data) => request({
  url: 'api/Register/Register',
  method: 'post',
  data: data
});

//注册用户加入组织
export const joinTenant = (data) => request({
  url: 'api/Register/Register',
  method: 'post',
  data: data
});

//校验验证码
export const checkValidationCode = (data) => request({
  url: 'api/checkValidationCode',
  method: 'post',
  params: data
});

//忘记密码
export const findPassword = (data) => request({
  url: 'api/User/RetrievePassword',
  method: 'post',
  data: data
});

//检查用户是否存在
export const CheckByUsername = (data) => request({
  url: 'api/User/CheckByUsername',
  method: 'get',
  params: data
});
